#include "Piece.h"

Piece::Piece(int color, int type, int x, int y) : _color(color), _type(type), _pos_x(x), _pos_y(y)
{
}

Sprite* Piece::createSprite(Piece *piece)
{
	ConfigMgr *cfg = ConfigMgr::getInstance();
	int width = cfg->getResourceWidth();
	string color = (piece->_color == kPieceColorBlack) ? kColorNameBlack : kColorNameRed;
	string type = kPieceNames[piece->_type];
	String *path = String::createWithFormat("%d/%s%s.png", width, color.c_str(), type.c_str());
	Sprite *sprite = Sprite::create(path->_string);
	sprite->setPosition(cfg->getGLCoord(piece->_pos_x, piece->_pos_y));
	sprite->setUserObject(piece);
	return sprite;
}
